<template>
  <div>
    <button @click="change">toggle</button>
    <!-- 动态组件，会随着条件的变化显示不同的内容 -->
    <!-- 主要是会切换的内容，就可以用transition包裹：div通过v-show控制、router-view、is属性 -->
    <transition name="aaa">
      <div :is="comName"></div>
    </transition>
    <!-- <transition name="bbb">
      <div :is="comName"></div>
    </transition> -->
  </div>
</template>

<script>
import List from "./List.vue";
import Hello from "./Hello.vue";
export default {
  data() {
    return {
      comName: "List",
    };
  },
  components: {
    List,
    Hello,
  },
  methods: {
    change() {
      if (this.comName == "List") {
        this.comName = "Hello";
      } else {
        this.comName = "List";
      }
    },
  },
};
</script>

<style>
.aaa-enter-active {
  transition: all 0.3s ease;
}
.aaa-leave-active {
  transition: all 0.8s cubic-bezier(1, 0.5, 0.8, 1);
}
.aaa-enter,
.aaa-leave-to {
  transform: translateX(10px);
  opacity: 0;
}

.ani-enter-active {
  animation: bounce-in 0.5s;
}

@keyframes bounce-in {
  0% {
    transform: scale(0);
  }
  50% {
    transform: scale(1.5);
  }
  100% {
    transform: scale(1);
  }
}
</style>